Climate Change

How Global Temperatures have changed since the Industrial Revolution and their relationship with GDP

Authors

Suraj Karakulath

Modou Lamin Manjang (Momo)

Gillian Baez Colon

Published

December 1, 2022

Abstract
This report analyzes global temperature changes using deviations from a baseline and determines the relationship between GDP and temperature deviation via a linear model. Temperatures have increased globally throughout the years with a sharper increase in the last 50 years. The relationship between global temperatures and GDP is not entirely clear.

Introduction

Climate change refers to the long-term shifts in weather and temperature patterns driven by human activities. The effects of these shifts are catastrophic natural disasters, extinctions, forced migrations, and more. While there is an overwhelming amount of climate data available, there are yet to be significant achievements in the world of climate data science because of the complex nature of the data. Nevertheless, the field is progressing, thus, developing models to understand and predict climate change.

Berkeley Earth put together the data set, which compiles three of the most cited land and ocean temperature data sets: NOAA’s MLOST, NASA’s GISTEMP, and the UK’s HadCrut. It combines 1.6 billion temperature reports from 16 pre-existing archives, including Global Land and Ocean-and-Land Temperatures (GlobalTemperatures.csv), which tracks the average land and ocean temperatures from 1750 along with their uncertainties and their maximums and minimums (from 1850) until 2015. Additionally, it contains sheets that slice the data by country, state, and city.

We intend to explore how temperatures have risen worldwide since 1750 and which regions (countries) have experienced the most extreme changes using the land and ocean temperature variables and country names. Then, we plan to determine the relationship between ta country’s GDP and climate change using temperature variables.

Our team selected these research questions because they work with the complex spatiotemporal nature of the data, which is often an obstacle when incorporating traditional data science methods and principles. While it is a common belief that temperatures have risen and will continue to do so (global warming), it is also likely that the fall and winter seasons will become colder. Our goal is to visualize these deviations in temperature since the Industrial Revolution and determine which regions have been affected the most. We hypothesize that temperatures have deviated the most in the last 50 years and countries with lower GDPs have been affected the most.

Data

Data source: https://www.kaggle.com/datasets/berkeleyearth/climate-change-earth-surface-temperature-data

Code
library(tidyverse)
── Attaching packages ─────────────────────────────────────── tidyverse 1.3.2 ──
✔ ggplot2 3.4.0      ✔ purrr   0.3.4 
✔ tibble  3.1.8      ✔ dplyr   1.0.10
✔ tidyr   1.2.0      ✔ stringr 1.4.1 
✔ readr   2.1.2      ✔ forcats 0.5.2 
── Conflicts ────────────────────────────────────────── tidyverse_conflicts() ──
✖ dplyr::filter() masks stats::filter()
✖ dplyr::lag()    masks stats::lag()
Code
library(dplyr)
library(patchwork)

suppressPackageStartupMessages(library(tidyverse))
suppressPackageStartupMessages(library(dplyr))
suppressPackageStartupMessages(library(patchwork))

global_temp_country <- read_csv("GlobalLandTemperaturesByCountry.csv")
Rows: 577462 Columns: 4
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
chr  (1): Country
dbl  (2): AverageTemperature, AverageTemperatureUncertainty
date (1): dt

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.
Code
global_temp <- read_csv("GlobalTemperatures.csv")
Rows: 3192 Columns: 9
── Column specification ────────────────────────────────────────────────────────
Delimiter: ","
dbl  (8): LandAverageTemperature, LandAverageTemperatureUncertainty, LandMax...
date (1): dt

ℹ Use `spec()` to retrieve the full column specification for this data.
ℹ Specify the column types or set `show_col_types = FALSE` to quiet this message.

Cleaning and Exploration

Code
head(global_temp)
# A tibble: 6 × 9
  dt         LandAvera…¹ LandA…² LandM…³ LandM…⁴ LandM…⁵ LandM…⁶ LandA…⁷ LandA…⁸
  <date>           <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
1 1750-01-01        3.03    3.57      NA      NA      NA      NA      NA      NA
2 1750-02-01        3.08    3.70      NA      NA      NA      NA      NA      NA
3 1750-03-01        5.63    3.08      NA      NA      NA      NA      NA      NA
4 1750-04-01        8.49    2.45      NA      NA      NA      NA      NA      NA
5 1750-05-01       11.6     2.07      NA      NA      NA      NA      NA      NA
6 1750-06-01       12.9     1.72      NA      NA      NA      NA      NA      NA
# … with abbreviated variable names ¹​LandAverageTemperature,
#   ²​LandAverageTemperatureUncertainty, ³​LandMaxTemperature,
#   ⁴​LandMaxTemperatureUncertainty, ⁵​LandMinTemperature,
#   ⁶​LandMinTemperatureUncertainty, ⁷​LandAndOceanAverageTemperature,
#   ⁸​LandAndOceanAverageTemperatureUncertainty
Code
dim(global_temp) #3192 x 9
[1] 3192    9

Global_temp contains 3192 observations of 9 variables.

Code
str(global_temp)
spc_tbl_ [3,192 × 9] (S3: spec_tbl_df/tbl_df/tbl/data.frame)
 $ dt                                       : Date[1:3192], format: "1750-01-01" "1750-02-01" ...
 $ LandAverageTemperature                   : num [1:3192] 3.03 3.08 5.63 8.49 11.57 ...
 $ LandAverageTemperatureUncertainty        : num [1:3192] 3.57 3.7 3.08 2.45 2.07 ...
 $ LandMaxTemperature                       : num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 $ LandMaxTemperatureUncertainty            : num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 $ LandMinTemperature                       : num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 $ LandMinTemperatureUncertainty            : num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 $ LandAndOceanAverageTemperature           : num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 $ LandAndOceanAverageTemperatureUncertainty: num [1:3192] NA NA NA NA NA NA NA NA NA NA ...
 - attr(*, "spec")=
  .. cols(
  ..   dt = col_date(format = ""),
  ..   LandAverageTemperature = col_double(),
  ..   LandAverageTemperatureUncertainty = col_double(),
  ..   LandMaxTemperature = col_double(),
  ..   LandMaxTemperatureUncertainty = col_double(),
  ..   LandMinTemperature = col_double(),
  ..   LandMinTemperatureUncertainty = col_double(),
  ..   LandAndOceanAverageTemperature = col_double(),
  ..   LandAndOceanAverageTemperatureUncertainty = col_double()
  .. )
 - attr(*, "problems")=<externalptr> 

The dt variable is already in date-time type while all others are numbers for the temperature and their uncertainties.

Code
summary(global_temp)
       dt             LandAverageTemperature LandAverageTemperatureUncertainty
 Min.   :1750-01-01   Min.   :-2.080         Min.   :0.0340                   
 1st Qu.:1816-06-23   1st Qu.: 4.312         1st Qu.:0.1867                   
 Median :1882-12-16   Median : 8.611         Median :0.3920                   
 Mean   :1882-12-15   Mean   : 8.375         Mean   :0.9385                   
 3rd Qu.:1949-06-08   3rd Qu.:12.548         3rd Qu.:1.4192                   
 Max.   :2015-12-01   Max.   :19.021         Max.   :7.8800                   
                      NA's   :12             NA's   :12                       
 LandMaxTemperature LandMaxTemperatureUncertainty LandMinTemperature
 Min.   : 5.90      Min.   :0.0440                Min.   :-5.407    
 1st Qu.:10.21      1st Qu.:0.1420                1st Qu.:-1.335    
 Median :14.76      Median :0.2520                Median : 2.950    
 Mean   :14.35      Mean   :0.4798                Mean   : 2.744    
 3rd Qu.:18.45      3rd Qu.:0.5390                3rd Qu.: 6.779    
 Max.   :21.32      Max.   :4.3730                Max.   : 9.715    
 NA's   :1200       NA's   :1200                  NA's   :1200      
 LandMinTemperatureUncertainty LandAndOceanAverageTemperature
 Min.   :0.0450                Min.   :12.47                 
 1st Qu.:0.1550                1st Qu.:14.05                 
 Median :0.2790                Median :15.25                 
 Mean   :0.4318                Mean   :15.21                 
 3rd Qu.:0.4582                3rd Qu.:16.40                 
 Max.   :3.4980                Max.   :17.61                 
 NA's   :1200                  NA's   :1200                  
 LandAndOceanAverageTemperatureUncertainty
 Min.   :0.0420                           
 1st Qu.:0.0630                           
 Median :0.1220                           
 Mean   :0.1285                           
 3rd Qu.:0.1510                           
 Max.   :0.4570                           
 NA's   :1200                             

The dates range from 1750-01-01 to 2015-12-01. So (2015-1750)*12+12 = 3192 dates (for every month), which matches our number of rows in the dataset. We have one unique record for every month.

Code
print("Count of missing values by column wise")
[1] "Count of missing values by column wise"
Code
sapply(global_temp, function(x) sum(is.na(x)))
                                       dt 
                                        0 
                   LandAverageTemperature 
                                       12 
        LandAverageTemperatureUncertainty 
                                       12 
                       LandMaxTemperature 
                                     1200 
            LandMaxTemperatureUncertainty 
                                     1200 
                       LandMinTemperature 
                                     1200 
            LandMinTemperatureUncertainty 
                                     1200 
           LandAndOceanAverageTemperature 
                                     1200 
LandAndOceanAverageTemperatureUncertainty 
                                     1200 

There are missing values for all variables except date. LandAverageTemperature and its uncertainty has 12 missing values, while the rest of the temperature columns have 1200 missing values each.

We want to find out which are the dates for which there are missing values.

First, the missing values for LandAverageTemperature:

Code
global_temp |> subset(is.na(LandAverageTemperature)) |> arrange(dt)
# A tibble: 12 × 9
   dt         LandAver…¹ LandA…² LandM…³ LandM…⁴ LandM…⁵ LandM…⁶ LandA…⁷ LandA…⁸
   <date>          <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 1750-11-01         NA      NA      NA      NA      NA      NA      NA      NA
 2 1751-05-01         NA      NA      NA      NA      NA      NA      NA      NA
 3 1751-07-01         NA      NA      NA      NA      NA      NA      NA      NA
 4 1751-10-01         NA      NA      NA      NA      NA      NA      NA      NA
 5 1751-11-01         NA      NA      NA      NA      NA      NA      NA      NA
 6 1751-12-01         NA      NA      NA      NA      NA      NA      NA      NA
 7 1752-02-01         NA      NA      NA      NA      NA      NA      NA      NA
 8 1752-05-01         NA      NA      NA      NA      NA      NA      NA      NA
 9 1752-06-01         NA      NA      NA      NA      NA      NA      NA      NA
10 1752-07-01         NA      NA      NA      NA      NA      NA      NA      NA
11 1752-08-01         NA      NA      NA      NA      NA      NA      NA      NA
12 1752-09-01         NA      NA      NA      NA      NA      NA      NA      NA
# … with abbreviated variable names ¹​LandAverageTemperature,
#   ²​LandAverageTemperatureUncertainty, ³​LandMaxTemperature,
#   ⁴​LandMaxTemperatureUncertainty, ⁵​LandMinTemperature,
#   ⁶​LandMinTemperatureUncertainty, ⁷​LandAndOceanAverageTemperature,
#   ⁸​LandAndOceanAverageTemperatureUncertainty

They seem to be random dates: one day in Nov 1, 1750, then months May, July, Oct, Nov, Dec in 1751 and then Feb, May, Jun, Jul in 1752. There are only 10 visible. These are only a few entries compared to the total number of observations. And when we do use them later, it will usually be in aggregation functions like mean, where the na.rm=TRUE parameter will take care of removing them.

For the LandMaxTemperature, the 1200 missing values are:

Code
global_temp |> subset(is.na(LandMaxTemperature)) |> arrange(dt)
# A tibble: 1,200 × 9
   dt         LandAver…¹ LandA…² LandM…³ LandM…⁴ LandM…⁵ LandM…⁶ LandA…⁷ LandA…⁸
   <date>          <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>   <dbl>
 1 1750-01-01       3.03    3.57      NA      NA      NA      NA      NA      NA
 2 1750-02-01       3.08    3.70      NA      NA      NA      NA      NA      NA
 3 1750-03-01       5.63    3.08      NA      NA      NA      NA      NA      NA
 4 1750-04-01       8.49    2.45      NA      NA      NA      NA      NA      NA
 5 1750-05-01      11.6     2.07      NA      NA      NA      NA      NA      NA
 6 1750-06-01      12.9     1.72      NA      NA      NA      NA      NA      NA
 7 1750-07-01      15.9     1.91      NA      NA      NA      NA      NA      NA
 8 1750-08-01      14.8     2.23      NA      NA      NA      NA      NA      NA
 9 1750-09-01      11.4     2.64      NA      NA      NA      NA      NA      NA
10 1750-10-01       6.37    2.67      NA      NA      NA      NA      NA      NA
# … with 1,190 more rows, and abbreviated variable names
#   ¹​LandAverageTemperature, ²​LandAverageTemperatureUncertainty,
#   ³​LandMaxTemperature, ⁴​LandMaxTemperatureUncertainty, ⁵​LandMinTemperature,
#   ⁶​LandMinTemperatureUncertainty, ⁷​LandAndOceanAverageTemperature,
#   ⁸​LandAndOceanAverageTemperatureUncertainty
Code
missing <- global_temp |> subset(is.na(LandMaxTemperature)) 
max(missing$dt)
[1] "1849-12-01"

These values are for all dates from Jan 1750 all the way to Dec 1849, for a total of 1200 rows. ((1849-1750)*12+12 =1200))

All of these have the other temperatures also missing.

We can remove these rows if we are working with these variables, but we are not going to be using the LandMaxTemperature anyway. So for now we will keep it to see how average temperatures have risen over the years.

Visualizations

How have temperatures risen across the world since 1750?

We hypothesize that global temperatures have risen since 1750, with a sharper increase in the last 50 years. We will confirm this by plotting the LandAverageTemperature against the date.

Code
global_temp |> ggplot(aes(dt,LandAverageTemperature)) + geom_point()
Warning: Removed 12 rows containing missing values (`geom_point()`).

There is a visible increase in the years from 1900 to 2000 and beyond, with 4-5 “bands” that most likely indicate seasons. The data from 1750 to 1850 has a bit more of noise/uncertainty. This “noise” may be the result of unstandardized data collection and multiple sources.

This displays the entire dataset with temperatures for every month, which fluctuate due to season in every location. We can smooth it out by breaking it down by year and decade or comparing months across the years.

Code
suppressPackageStartupMessages(library(lubridate))

 global_temp <- global_temp |> mutate(yearDt = year(dt),
                monthDt = month(dt),
                decadeDt = round(year(dt),-1),
                monthNames = format(dt,"%b"))

monthNames = format(as.Date(paste0('2000-',1:12,'-01'),'%Y-%m-%d'),"%b")
Code
names(global_temp)
 [1] "dt"                                       
 [2] "LandAverageTemperature"                   
 [3] "LandAverageTemperatureUncertainty"        
 [4] "LandMaxTemperature"                       
 [5] "LandMaxTemperatureUncertainty"            
 [6] "LandMinTemperature"                       
 [7] "LandMinTemperatureUncertainty"            
 [8] "LandAndOceanAverageTemperature"           
 [9] "LandAndOceanAverageTemperatureUncertainty"
[10] "yearDt"                                   
[11] "monthDt"                                  
[12] "decadeDt"                                 
[13] "monthNames"                               
Code
global_temp |> group_by(yearDt) |> 
    summarise(LandAverageTemperature = mean(LandAverageTemperature,na.rm=TRUE)) %>%
    ggplot(aes( x=yearDt, y=LandAverageTemperature, colour=LandAverageTemperature)) +
    geom_point(alpha=0.25) +
    theme(panel.background = element_rect(fill='white')) 

There is a clear rise in the average temperature over the last two centuries and a steep rise in the last 10-20 years. This proves our hypothesis somewhat that the sharpest increase has occurred within the last 50 years.

The decade distribution shows the same increase:

Code
global_temp |> group_by(decadeDt) |> 
    summarise(LandAverageTemperature = mean(LandAverageTemperature,na.rm=TRUE)) %>%
    ggplot(aes( x=decadeDt, y=LandAverageTemperature, colour=LandAverageTemperature)) +
    geom_point(alpha=0.25) +
    theme(panel.background = element_rect(fill='white')) 

Quantifying the rise

It is clear that global temperatures have risen and will likely continue to do so. We want to explore precisely how much they have been increasing. For this, we need a metric to identify how far the LandAverageTemperature has deviated from a baseline that makes sense.

Climate science is a constantly evolving field; different models use different baselines. The baseline period is chosen depending on the specific research question addressed, the availability of data for that time, and the ability of the model to accurately simulate climate conditions over that period.

Some studies use the first 100 years of available data as a baseline. While other more recent climate models, such as paleoclimate ones, use pre-Industrial Revolution years as a baseline. This accounts for the significant effects of industrialization on climate.

We selected the average of the previous 100 years (1750 to 1850) as an initial baseline to compare how the average temperatures have risen since 1850.

Code
first <- global_temp |> filter(dt >= '1750-01-01' & dt <= '1849-12-01')
global_mean <- mean(first$LandAverageTemperature, na.rm = TRUE)
Code
global_temp |> mutate(departure = global_temp$LandAverageTemperature - global_mean) |> filter(dt >= '1850-01-01') |> group_by(yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(yearDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_year >= 0, departure_by_year, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_year < 0, departure_by_year, 0), fill= "blue")) +
   xlab("Year") + 
   ylab("Departure from baseline (1750-1850)") +
   scale_fill_manual(values = c("blue", "red")) + 
   theme(legend.position = "none")   

Code
global_temp |> mutate(departure = global_temp$LandAverageTemperature - global_mean) |> filter(dt >= '1850-01-01') |> group_by(decadeDt) |> summarise(departure_by_decade = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(decadeDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_decade >= 0, departure_by_decade, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_decade < 0, departure_by_decade, 0), fill= "blue")) +
  xlab("Decade") + 
  ylab("Departure from baseline (1750-1850") +
   scale_fill_manual(values = c("blue", "red"))+
   theme(legend.position = "none")   

Every decade the departure from baseline (on average for that decade) has increased.

Which countries have departed from the baseline the most?

For this, we explore the country dataset.

Code
#|label: summary
summary(global_temp_country)
       dt             AverageTemperature AverageTemperatureUncertainty
 Min.   :1743-11-01   Min.   :-37.66     Min.   : 0.05                
 1st Qu.:1862-12-01   1st Qu.: 10.03     1st Qu.: 0.32                
 Median :1914-04-01   Median : 20.90     Median : 0.57                
 Mean   :1909-04-11   Mean   : 17.19     Mean   : 1.02                
 3rd Qu.:1964-03-01   3rd Qu.: 25.81     3rd Qu.: 1.21                
 Max.   :2013-09-01   Max.   : 38.84     Max.   :15.00                
                      NA's   :32651      NA's   :31912                
   Country         
 Length:577462     
 Class :character  
 Mode  :character  
                   
                   
                   
                   

Dataset has only 4 variables: 1 datetime, 2 float for the temperature and uncertainty, and 1 character for the country name. The dates start earlier at 1743 November and end at September 2013.

Code
length(unique(global_temp_country$Country)) #243
[1] 243

There are 243 countries included with monthly AverageTemperature records for each country in that time period (with some missing values).

Code
dim(global_temp_country) #577462 x 4
[1] 577462      4
Code
print("Count of missing values by column wise")
[1] "Count of missing values by column wise"
Code
sapply(global_temp_country, function(x) sum(is.na(x)))
                           dt            AverageTemperature 
                            0                         32651 
AverageTemperatureUncertainty                       Country 
                        31912                             0 

Calculating departures from the baseline for each country

We calculate the departure of each country from the global mean and explore how much each country has deviated from their own baseline since different regions have different climate characteristics (e.g. a meaningful baseline for Russia may be too cold for Qatar, or the global mean may not be a meaningful baseline for Greenland).

Calculating the departure from their own mean AverageTemperature of the baseline years (before 1850).

Code
library(tidyr)
#Finding the baseline mean for each country first
country_temp_means <- global_temp_country |> filter(dt <= '1849-12-01' ) |> group_by(Country) |> summarise(country_mean = mean(AverageTemperature,na.rm=TRUE))

Now ranking the countries with the maximum departure from their own mean for the baseline years.

Code
country_dep <- global_temp_country |> left_join(country_temp_means, by = 'Country') |> 
  mutate(departure = AverageTemperature - country_mean) 


country_dep |> group_by(Country) |> summarise(max_departure = max(departure,na.rm = TRUE)) |> arrange(desc(max_departure)) |> suppressWarnings() 
# A tibble: 243 × 2
   Country      max_departure
   <chr>                <dbl>
 1 Russia                23.0
 2 Mongolia              22.1
 3 Kazakhstan            20.9
 4 Canada                20.7
 5 Greenland             19.4
 6 Denmark               19.2
 7 Uzbekistan            19.0
 8 Turkmenistan          18.2
 9 Finland               18.2
10 Estonia               17.8
# … with 233 more rows
Code
#had to suppress warnings due to a complex warning message "no non-missing arguments to min" etc.

The countries that have the highest departures from their own baseline turn out to be some of the colder countries, suggesting that these regions are seeing the biggest impact of climate change.

Plot their departures from 1970 to the end:

Code
 country_dep <- country_dep |> mutate(yearDt = year(dt),
                monthDt = month(dt),
                decadeDt = round(year(dt),-1),
                monthNames = format(dt,"%b"))

monthNames = format(as.Date(paste0('2000-',1:12,'-01'),'%Y-%m-%d'),"%b")
Code
country_dep |> filter(Country == 'Russia' & dt >= '1970-01-01') |> 
    group_by(yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(yearDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_year >= 0, departure_by_year, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_year < 0, departure_by_year, 0), fill= "blue")) +
   xlab("Year") +
   ylab("Departure from baseline (until 1850)") +
   scale_fill_manual(values = c("blue", "red")) +
   theme(legend.position = "none")   

Code
country_dep |> filter(Country == 'Mongolia' & dt >= '1970-01-01') |> 
  group_by(yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(yearDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_year >= 0, departure_by_year, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_year < 0, departure_by_year, 0), fill= "blue")) +
   xlab("Year") +
   ylab("Departure from baseline (until 1850)") +
   scale_fill_manual(values = c("blue", "red")) + 
   theme(legend.position = "none")   

Code
country_dep |> filter(Country == 'Kazakhstan' & dt >= '1970-01-01') |> 
  group_by(yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(yearDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_year >= 0, departure_by_year, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_year < 0, departure_by_year, 0), fill= "blue")) +
   xlab("Year") +
   ylab("Departure from baseline (until 1850) ") +
   scale_fill_manual(values = c("blue", "red")) + 
  theme(legend.position = "none")   

Code
country_dep |> filter(Country == 'Kuwait' & dt >= '1970-01-01') |> 
  group_by(yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |>
  ggplot(aes(yearDt)) + 
   geom_col(mapping=aes(y=ifelse(departure_by_year >= 0, departure_by_year, 0), fill = "red"))+
   geom_col(mapping=aes(y=ifelse(departure_by_year < 0, departure_by_year, 0), fill= "blue")) +
   xlab("Year") +
   ylab("Departure from baseline (until 1850)") +
   scale_fill_manual(values = c("blue", "red")) + 
   theme(legend.position = "none")   

As seen in each of the plots, the departures from the baseline years of each country since 1970 has been increasing all the way.

Which latitudes and longitudes have the highest departure from the baseline?

Let’s explore the temperature changes at different latitudes and longitudes. For this we import a dataset that maps country codes with latitudes and longitudes.

Code
country_coordinates <- read.csv("world_country_and_usa_states_latitude_and_longitude_values.csv")
Code
dim(country_coordinates)
[1] 245   8

There are 245 rows here which means there are 2 countries which are not part of our original dataset. Let’s find out which ones.

Code
unique(country_dep$Country)
  [1] "Åland"                                    
  [2] "Afghanistan"                              
  [3] "Africa"                                   
  [4] "Albania"                                  
  [5] "Algeria"                                  
  [6] "American Samoa"                           
  [7] "Andorra"                                  
  [8] "Angola"                                   
  [9] "Anguilla"                                 
 [10] "Antarctica"                               
 [11] "Antigua And Barbuda"                      
 [12] "Argentina"                                
 [13] "Armenia"                                  
 [14] "Aruba"                                    
 [15] "Asia"                                     
 [16] "Australia"                                
 [17] "Austria"                                  
 [18] "Azerbaijan"                               
 [19] "Bahamas"                                  
 [20] "Bahrain"                                  
 [21] "Baker Island"                             
 [22] "Bangladesh"                               
 [23] "Barbados"                                 
 [24] "Belarus"                                  
 [25] "Belgium"                                  
 [26] "Belize"                                   
 [27] "Benin"                                    
 [28] "Bhutan"                                   
 [29] "Bolivia"                                  
 [30] "Bonaire, Saint Eustatius And Saba"        
 [31] "Bosnia And Herzegovina"                   
 [32] "Botswana"                                 
 [33] "Brazil"                                   
 [34] "British Virgin Islands"                   
 [35] "Bulgaria"                                 
 [36] "Burkina Faso"                             
 [37] "Burma"                                    
 [38] "Burundi"                                  
 [39] "Côte D'Ivoire"                            
 [40] "Cambodia"                                 
 [41] "Cameroon"                                 
 [42] "Canada"                                   
 [43] "Cape Verde"                               
 [44] "Cayman Islands"                           
 [45] "Central African Republic"                 
 [46] "Chad"                                     
 [47] "Chile"                                    
 [48] "China"                                    
 [49] "Christmas Island"                         
 [50] "Colombia"                                 
 [51] "Comoros"                                  
 [52] "Congo (Democratic Republic Of The)"       
 [53] "Congo"                                    
 [54] "Costa Rica"                               
 [55] "Croatia"                                  
 [56] "Cuba"                                     
 [57] "Curaçao"                                  
 [58] "Cyprus"                                   
 [59] "Czech Republic"                           
 [60] "Denmark (Europe)"                         
 [61] "Denmark"                                  
 [62] "Djibouti"                                 
 [63] "Dominica"                                 
 [64] "Dominican Republic"                       
 [65] "Ecuador"                                  
 [66] "Egypt"                                    
 [67] "El Salvador"                              
 [68] "Equatorial Guinea"                        
 [69] "Eritrea"                                  
 [70] "Estonia"                                  
 [71] "Ethiopia"                                 
 [72] "Europe"                                   
 [73] "Falkland Islands (Islas Malvinas)"        
 [74] "Faroe Islands"                            
 [75] "Federated States Of Micronesia"           
 [76] "Fiji"                                     
 [77] "Finland"                                  
 [78] "France (Europe)"                          
 [79] "France"                                   
 [80] "French Guiana"                            
 [81] "French Polynesia"                         
 [82] "French Southern And Antarctic Lands"      
 [83] "Gabon"                                    
 [84] "Gambia"                                   
 [85] "Gaza Strip"                               
 [86] "Georgia"                                  
 [87] "Germany"                                  
 [88] "Ghana"                                    
 [89] "Greece"                                   
 [90] "Greenland"                                
 [91] "Grenada"                                  
 [92] "Guadeloupe"                               
 [93] "Guam"                                     
 [94] "Guatemala"                                
 [95] "Guernsey"                                 
 [96] "Guinea Bissau"                            
 [97] "Guinea"                                   
 [98] "Guyana"                                   
 [99] "Haiti"                                    
[100] "Heard Island And Mcdonald Islands"        
[101] "Honduras"                                 
[102] "Hong Kong"                                
[103] "Hungary"                                  
[104] "Iceland"                                  
[105] "India"                                    
[106] "Indonesia"                                
[107] "Iran"                                     
[108] "Iraq"                                     
[109] "Ireland"                                  
[110] "Isle Of Man"                              
[111] "Israel"                                   
[112] "Italy"                                    
[113] "Jamaica"                                  
[114] "Japan"                                    
[115] "Jersey"                                   
[116] "Jordan"                                   
[117] "Kazakhstan"                               
[118] "Kenya"                                    
[119] "Kingman Reef"                             
[120] "Kiribati"                                 
[121] "Kuwait"                                   
[122] "Kyrgyzstan"                               
[123] "Laos"                                     
[124] "Latvia"                                   
[125] "Lebanon"                                  
[126] "Lesotho"                                  
[127] "Liberia"                                  
[128] "Libya"                                    
[129] "Liechtenstein"                            
[130] "Lithuania"                                
[131] "Luxembourg"                               
[132] "Macau"                                    
[133] "Macedonia"                                
[134] "Madagascar"                               
[135] "Malawi"                                   
[136] "Malaysia"                                 
[137] "Mali"                                     
[138] "Malta"                                    
[139] "Martinique"                               
[140] "Mauritania"                               
[141] "Mauritius"                                
[142] "Mayotte"                                  
[143] "Mexico"                                   
[144] "Moldova"                                  
[145] "Monaco"                                   
[146] "Mongolia"                                 
[147] "Montenegro"                               
[148] "Montserrat"                               
[149] "Morocco"                                  
[150] "Mozambique"                               
[151] "Namibia"                                  
[152] "Nepal"                                    
[153] "Netherlands (Europe)"                     
[154] "Netherlands"                              
[155] "New Caledonia"                            
[156] "New Zealand"                              
[157] "Nicaragua"                                
[158] "Niger"                                    
[159] "Nigeria"                                  
[160] "Niue"                                     
[161] "North America"                            
[162] "North Korea"                              
[163] "Northern Mariana Islands"                 
[164] "Norway"                                   
[165] "Oceania"                                  
[166] "Oman"                                     
[167] "Pakistan"                                 
[168] "Palau"                                    
[169] "Palestina"                                
[170] "Palmyra Atoll"                            
[171] "Panama"                                   
[172] "Papua New Guinea"                         
[173] "Paraguay"                                 
[174] "Peru"                                     
[175] "Philippines"                              
[176] "Poland"                                   
[177] "Portugal"                                 
[178] "Puerto Rico"                              
[179] "Qatar"                                    
[180] "Reunion"                                  
[181] "Romania"                                  
[182] "Russia"                                   
[183] "Rwanda"                                   
[184] "Saint Barthélemy"                         
[185] "Saint Kitts And Nevis"                    
[186] "Saint Lucia"                              
[187] "Saint Martin"                             
[188] "Saint Pierre And Miquelon"                
[189] "Saint Vincent And The Grenadines"         
[190] "Samoa"                                    
[191] "San Marino"                               
[192] "Sao Tome And Principe"                    
[193] "Saudi Arabia"                             
[194] "Senegal"                                  
[195] "Serbia"                                   
[196] "Seychelles"                               
[197] "Sierra Leone"                             
[198] "Singapore"                                
[199] "Sint Maarten"                             
[200] "Slovakia"                                 
[201] "Slovenia"                                 
[202] "Solomon Islands"                          
[203] "Somalia"                                  
[204] "South Africa"                             
[205] "South America"                            
[206] "South Georgia And The South Sandwich Isla"
[207] "South Korea"                              
[208] "Spain"                                    
[209] "Sri Lanka"                                
[210] "Sudan"                                    
[211] "Suriname"                                 
[212] "Svalbard And Jan Mayen"                   
[213] "Swaziland"                                
[214] "Sweden"                                   
[215] "Switzerland"                              
[216] "Syria"                                    
[217] "Taiwan"                                   
[218] "Tajikistan"                               
[219] "Tanzania"                                 
[220] "Thailand"                                 
[221] "Timor Leste"                              
[222] "Togo"                                     
[223] "Tonga"                                    
[224] "Trinidad And Tobago"                      
[225] "Tunisia"                                  
[226] "Turkey"                                   
[227] "Turkmenistan"                             
[228] "Turks And Caicas Islands"                 
[229] "Uganda"                                   
[230] "Ukraine"                                  
[231] "United Arab Emirates"                     
[232] "United Kingdom (Europe)"                  
[233] "United Kingdom"                           
[234] "United States"                            
[235] "Uruguay"                                  
[236] "Uzbekistan"                               
[237] "Venezuela"                                
[238] "Vietnam"                                  
[239] "Virgin Islands"                           
[240] "Western Sahara"                           
[241] "Yemen"                                    
[242] "Zambia"                                   
[243] "Zimbabwe"                                 
Code
#|label: unique country coordinates
unique(country_coordinates$country)
  [1] "Andorra"                                     
  [2] "United Arab Emirates"                        
  [3] "Afghanistan"                                 
  [4] "Antigua and Barbuda"                         
  [5] "Anguilla"                                    
  [6] "Albania"                                     
  [7] "Armenia"                                     
  [8] "Netherlands Antilles"                        
  [9] "Angola"                                      
 [10] "Antarctica"                                  
 [11] "Argentina"                                   
 [12] "American Samoa"                              
 [13] "Austria"                                     
 [14] "Australia"                                   
 [15] "Aruba"                                       
 [16] "Azerbaijan"                                  
 [17] "Bosnia and Herzegovina"                      
 [18] "Barbados"                                    
 [19] "Bangladesh"                                  
 [20] "Belgium"                                     
 [21] "Burkina Faso"                                
 [22] "Bulgaria"                                    
 [23] "Bahrain"                                     
 [24] "Burundi"                                     
 [25] "Benin"                                       
 [26] "Bermuda"                                     
 [27] "Brunei"                                      
 [28] "Bolivia"                                     
 [29] "Brazil"                                      
 [30] "Bahamas"                                     
 [31] "Bhutan"                                      
 [32] "Bouvet Island"                               
 [33] "Botswana"                                    
 [34] "Belarus"                                     
 [35] "Belize"                                      
 [36] "Canada"                                      
 [37] "Cocos [Keeling] Islands"                     
 [38] "Congo [DRC]"                                 
 [39] "Central African Republic"                    
 [40] "Congo [Republic]"                            
 [41] "Switzerland"                                 
 [42] "Côte d'Ivoire"                               
 [43] "Cook Islands"                                
 [44] "Chile"                                       
 [45] "Cameroon"                                    
 [46] "China"                                       
 [47] "Colombia"                                    
 [48] "Costa Rica"                                  
 [49] "Cuba"                                        
 [50] "Cape Verde"                                  
 [51] "Christmas Island"                            
 [52] "Cyprus"                                      
 [53] "Czech Republic"                              
 [54] "Germany"                                     
 [55] "Djibouti"                                    
 [56] "Denmark"                                     
 [57] "Dominica"                                    
 [58] "Dominican Republic"                          
 [59] "Algeria"                                     
 [60] "Ecuador"                                     
 [61] "Estonia"                                     
 [62] "Egypt"                                       
 [63] "Western Sahara"                              
 [64] "Eritrea"                                     
 [65] "Spain"                                       
 [66] "Ethiopia"                                    
 [67] "Finland"                                     
 [68] "Fiji"                                        
 [69] "Falkland Islands [Islas Malvinas]"           
 [70] "Micronesia"                                  
 [71] "Faroe Islands"                               
 [72] "France"                                      
 [73] "Gabon"                                       
 [74] "United Kingdom"                              
 [75] "Grenada"                                     
 [76] "Georgia"                                     
 [77] "French Guiana"                               
 [78] "Guernsey"                                    
 [79] "Ghana"                                       
 [80] "Gibraltar"                                   
 [81] "Greenland"                                   
 [82] "Gambia"                                      
 [83] "Guinea"                                      
 [84] "Guadeloupe"                                  
 [85] "Equatorial Guinea"                           
 [86] "Greece"                                      
 [87] "South Georgia and the South Sandwich Islands"
 [88] "Guatemala"                                   
 [89] "Guam"                                        
 [90] "Guinea-Bissau"                               
 [91] "Guyana"                                      
 [92] "Gaza Strip"                                  
 [93] "Hong Kong"                                   
 [94] "Heard Island and McDonald Islands"           
 [95] "Honduras"                                    
 [96] "Croatia"                                     
 [97] "Haiti"                                       
 [98] "Hungary"                                     
 [99] "Indonesia"                                   
[100] "Ireland"                                     
[101] "Israel"                                      
[102] "Isle of Man"                                 
[103] "India"                                       
[104] "British Indian Ocean Territory"              
[105] "Iraq"                                        
[106] "Iran"                                        
[107] "Iceland"                                     
[108] "Italy"                                       
[109] "Jersey"                                      
[110] "Jamaica"                                     
[111] "Jordan"                                      
[112] "Japan"                                       
[113] "Kenya"                                       
[114] "Kyrgyzstan"                                  
[115] "Cambodia"                                    
[116] "Kiribati"                                    
[117] "Comoros"                                     
[118] "Saint Kitts and Nevis"                       
[119] "North Korea"                                 
[120] "South Korea"                                 
[121] "Kuwait"                                      
[122] "Cayman Islands"                              
[123] "Kazakhstan"                                  
[124] "Laos"                                        
[125] "Lebanon"                                     
[126] "Saint Lucia"                                 
[127] "Liechtenstein"                               
[128] "Sri Lanka"                                   
[129] "Liberia"                                     
[130] "Lesotho"                                     
[131] "Lithuania"                                   
[132] "Luxembourg"                                  
[133] "Latvia"                                      
[134] "Libya"                                       
[135] "Morocco"                                     
[136] "Monaco"                                      
[137] "Moldova"                                     
[138] "Montenegro"                                  
[139] "Madagascar"                                  
[140] "Marshall Islands"                            
[141] "Macedonia [FYROM]"                           
[142] "Mali"                                        
[143] "Myanmar [Burma]"                             
[144] "Mongolia"                                    
[145] "Macau"                                       
[146] "Northern Mariana Islands"                    
[147] "Martinique"                                  
[148] "Mauritania"                                  
[149] "Montserrat"                                  
[150] "Malta"                                       
[151] "Mauritius"                                   
[152] "Maldives"                                    
[153] "Malawi"                                      
[154] "Mexico"                                      
[155] "Malaysia"                                    
[156] "Mozambique"                                  
[157] "Namibia"                                     
[158] "New Caledonia"                               
[159] "Niger"                                       
[160] "Norfolk Island"                              
[161] "Nigeria"                                     
[162] "Nicaragua"                                   
[163] "Netherlands"                                 
[164] "Norway"                                      
[165] "Nepal"                                       
[166] "Nauru"                                       
[167] "Niue"                                        
[168] "New Zealand"                                 
[169] "Oman"                                        
[170] "Panama"                                      
[171] "Peru"                                        
[172] "French Polynesia"                            
[173] "Papua New Guinea"                            
[174] "Philippines"                                 
[175] "Pakistan"                                    
[176] "Poland"                                      
[177] "Saint Pierre and Miquelon"                   
[178] "Pitcairn Islands"                            
[179] "Puerto Rico"                                 
[180] "Palestinian Territories"                     
[181] "Portugal"                                    
[182] "Palau"                                       
[183] "Paraguay"                                    
[184] "Qatar"                                       
[185] "Réunion"                                     
[186] "Romania"                                     
[187] "Serbia"                                      
[188] "Russia"                                      
[189] "Rwanda"                                      
[190] "Saudi Arabia"                                
[191] "Solomon Islands"                             
[192] "Seychelles"                                  
[193] "Sudan"                                       
[194] "Sweden"                                      
[195] "Singapore"                                   
[196] "Saint Helena"                                
[197] "Slovenia"                                    
[198] "Svalbard and Jan Mayen"                      
[199] "Slovakia"                                    
[200] "Sierra Leone"                                
[201] "San Marino"                                  
[202] "Senegal"                                     
[203] "Somalia"                                     
[204] "Suriname"                                    
[205] "São Tomé and Príncipe"                       
[206] "El Salvador"                                 
[207] "Syria"                                       
[208] "Swaziland"                                   
[209] "Turks and Caicos Islands"                    
[210] "Chad"                                        
[211] "French Southern Territories"                 
[212] "Togo"                                        
[213] "Thailand"                                    
[214] "Tajikistan"                                  
[215] "Tokelau"                                     
[216] "Timor-Leste"                                 
[217] "Turkmenistan"                                
[218] "Tunisia"                                     
[219] "Tonga"                                       
[220] "Turkey"                                      
[221] "Trinidad and Tobago"                         
[222] "Tuvalu"                                      
[223] "Taiwan"                                      
[224] "Tanzania"                                    
[225] "Ukraine"                                     
[226] "Uganda"                                      
[227] "U.S. Minor Outlying Islands"                 
[228] "United States"                               
[229] "Uruguay"                                     
[230] "Uzbekistan"                                  
[231] "Vatican City"                                
[232] "Saint Vincent and the Grenadines"            
[233] "Venezuela"                                   
[234] "British Virgin Islands"                      
[235] "U.S. Virgin Islands"                         
[236] "Vietnam"                                     
[237] "Vanuatu"                                     
[238] "Wallis and Futuna"                           
[239] "Samoa"                                       
[240] "Kosovo"                                      
[241] "Yemen"                                       
[242] "Mayotte"                                     
[243] "South Africa"                                
[244] "Zambia"                                      
[245] "Zimbabwe"                                    
Code
setdiff(country_dep$Country, country_coordinates$country)
 [1] "Åland"                                    
 [2] "Africa"                                   
 [3] "Antigua And Barbuda"                      
 [4] "Asia"                                     
 [5] "Baker Island"                             
 [6] "Bonaire, Saint Eustatius And Saba"        
 [7] "Bosnia And Herzegovina"                   
 [8] "Burma"                                    
 [9] "Côte D'Ivoire"                            
[10] "Congo (Democratic Republic Of The)"       
[11] "Congo"                                    
[12] "Curaçao"                                  
[13] "Denmark (Europe)"                         
[14] "Europe"                                   
[15] "Falkland Islands (Islas Malvinas)"        
[16] "Federated States Of Micronesia"           
[17] "France (Europe)"                          
[18] "French Southern And Antarctic Lands"      
[19] "Guinea Bissau"                            
[20] "Heard Island And Mcdonald Islands"        
[21] "Isle Of Man"                              
[22] "Kingman Reef"                             
[23] "Macedonia"                                
[24] "Netherlands (Europe)"                     
[25] "North America"                            
[26] "Oceania"                                  
[27] "Palestina"                                
[28] "Palmyra Atoll"                            
[29] "Reunion"                                  
[30] "Saint Barthélemy"                         
[31] "Saint Kitts And Nevis"                    
[32] "Saint Martin"                             
[33] "Saint Pierre And Miquelon"                
[34] "Saint Vincent And The Grenadines"         
[35] "Sao Tome And Principe"                    
[36] "Sint Maarten"                             
[37] "South America"                            
[38] "South Georgia And The South Sandwich Isla"
[39] "Svalbard And Jan Mayen"                   
[40] "Timor Leste"                              
[41] "Trinidad And Tobago"                      
[42] "Turks And Caicas Islands"                 
[43] "United Kingdom (Europe)"                  
[44] "Virgin Islands"                           

There are a few “countries” in our original dataset that are missing from the coordinates dataset. These are cases like

  • Åland - an autonomous region in Finland (which is best to be removed if it has temperature records for the same dates as Finland)

  • Caribbean countries like Antigua And Barbuda, Bonaire, Saint Eustatius And Saba, Curaçao (which have their own different unique cases such as being Dutch colonies so best to remove them) and French Southern and Antarctic Lands (which is an overseas Territory of France)

  • Islands like Baker Island (which can be removed)

  • Entire continents like Africa, Europe and Asia aggregated (which can be removed as we are only looking at individual countries)

  • Cases of minor change in spelling like capitalisation of A in Bosnia and Herzegovina, Côte d’Ivoire which is also spelled Côte D’Ivoire, Congo which is variously named as just Congo, Democratic Republic and other variations, Denmark which is also included as Denmark (Europe), France and France (Europe), Falkland Islands (Islas Malvinas) and its square bracket variation, Micronesia which also appears as Federated States of Micronesia (all of which are corrected to their simplest versions, Burma which was the name of Myanmar until 1989)

Code
country_dep$Country <- gsub("France\\(Europe\\)", "France", country_dep$Country)
country_dep$Country <- gsub("Denmark\\(Europe\\)", "Denmark", country_dep$Country)
country_dep$Country <- gsub("Netherlands\\(Europe\\)", "Netherlands", country_dep$Country)
country_dep$Country <- gsub("Federated States Of Micronesia", "Micronesia", country_dep$Country)
country_dep$Country <- gsub("United Kingdom\\(Europe\\)", "United Kingdom", country_dep$Country)
country_dep$Country <- gsub("Burma", "Myanmar", country_dep$Country)
country_dep$Country <- gsub("Congo", "Congo", country_dep$Country)
country_dep$Country <- gsub("Bosnia And Herzegovina", "Bosnia and Herzegovina", country_dep$Country)
country_dep$Country <- gsub("Côte D'Ivoire", "Côte d'Ivoire", country_dep$Country)
Code
country_dep <- country_dep[!country_dep$Country %in% c("Åland", "Asia", "Africa","Europe","North America","Oceania","South America"),]

We map the countries to their corresponding average temperatures and departures, and only select the necessary variables.

Code
country_temps <- country_coordinates |>
  inner_join(country_dep, by = c("country" = "Country")) |>
  select(latitude, longitude, country, dt, yearDt, monthDt, decadeDt, monthNames, AverageTemperature, departure)

What does the temperature change look like on a global scale over the years?

For this, we use an interactive world map to show the latitude and longitudes for the countries, a color grading to show the temperature change (average of departures for each year) and the time dimension (year) as a movable slider.

Code
with_dep_by_year <- country_temps |> group_by(country, yearDt) |> summarise(departure_by_year = mean(departure, na.rm = TRUE)) |> suppressMessages()
  
#the above line has created a dataframe with country,yearDT and the average of departures for that year for each country. Now all we need is the latitude and longitude coordinates to map back to the country

map_data <- country_coordinates |>  left_join(with_dep_by_year, by = c("country" = "country")) |> select(latitude, longitude, country, yearDt, departure_by_year) 
Code
suppressPackageStartupMessages(library(plotly))
plot_geo(map_data, 
         lon = ~longitude, 
         lat = ~latitude, 
         color=~map_data$departure_by_year, 
         frame = map_data$yearDt)
No scattergeo mode specifed:
  Setting the mode to markers
  Read more about this attribute -> https://plotly.com/r/reference/#scatter-mode
Warning: Ignoring 1 observations

As the years go buy, all the dark spots turn to green or closer to green, suggesting that on average the departures from the baseline for each country is increasing every year.

Analysis

In this section, we used a linear model to determine if there is any correlation between a country’s GDP and their deviation from the baseline temperature. We import a new dataset for GDP and clean it to be able to match our countries.

Code
dta <- read.csv("gdp.csv")
unique(with_dep_by_year$country)
  [1] "Afghanistan"              "Albania"                 
  [3] "Algeria"                  "American Samoa"          
  [5] "Andorra"                  "Angola"                  
  [7] "Anguilla"                 "Antarctica"              
  [9] "Argentina"                "Armenia"                 
 [11] "Aruba"                    "Australia"               
 [13] "Austria"                  "Azerbaijan"              
 [15] "Bahamas"                  "Bahrain"                 
 [17] "Bangladesh"               "Barbados"                
 [19] "Belarus"                  "Belgium"                 
 [21] "Belize"                   "Benin"                   
 [23] "Bhutan"                   "Bolivia"                 
 [25] "Bosnia and Herzegovina"   "Botswana"                
 [27] "Brazil"                   "British Virgin Islands"  
 [29] "Bulgaria"                 "Burkina Faso"            
 [31] "Burundi"                  "Cambodia"                
 [33] "Cameroon"                 "Canada"                  
 [35] "Cape Verde"               "Cayman Islands"          
 [37] "Central African Republic" "Chad"                    
 [39] "Chile"                    "China"                   
 [41] "Christmas Island"         "Colombia"                
 [43] "Comoros"                  "Costa Rica"              
 [45] "Côte d'Ivoire"            "Croatia"                 
 [47] "Cuba"                     "Cyprus"                  
 [49] "Czech Republic"           "Denmark"                 
 [51] "Djibouti"                 "Dominica"                
 [53] "Dominican Republic"       "Ecuador"                 
 [55] "Egypt"                    "El Salvador"             
 [57] "Equatorial Guinea"        "Eritrea"                 
 [59] "Estonia"                  "Ethiopia"                
 [61] "Faroe Islands"            "Fiji"                    
 [63] "Finland"                  "France"                  
 [65] "French Guiana"            "French Polynesia"        
 [67] "Gabon"                    "Gambia"                  
 [69] "Gaza Strip"               "Georgia"                 
 [71] "Germany"                  "Ghana"                   
 [73] "Greece"                   "Greenland"               
 [75] "Grenada"                  "Guadeloupe"              
 [77] "Guam"                     "Guatemala"               
 [79] "Guernsey"                 "Guinea"                  
 [81] "Guyana"                   "Haiti"                   
 [83] "Honduras"                 "Hong Kong"               
 [85] "Hungary"                  "Iceland"                 
 [87] "India"                    "Indonesia"               
 [89] "Iran"                     "Iraq"                    
 [91] "Ireland"                  "Israel"                  
 [93] "Italy"                    "Jamaica"                 
 [95] "Japan"                    "Jersey"                  
 [97] "Jordan"                   "Kazakhstan"              
 [99] "Kenya"                    "Kiribati"                
[101] "Kuwait"                   "Kyrgyzstan"              
[103] "Laos"                     "Latvia"                  
[105] "Lebanon"                  "Lesotho"                 
[107] "Liberia"                  "Libya"                   
[109] "Liechtenstein"            "Lithuania"               
[111] "Luxembourg"               "Macau"                   
[113] "Madagascar"               "Malawi"                  
[115] "Malaysia"                 "Mali"                    
[117] "Malta"                    "Martinique"              
[119] "Mauritania"               "Mauritius"               
[121] "Mayotte"                  "Mexico"                  
[123] "Micronesia"               "Moldova"                 
[125] "Monaco"                   "Mongolia"                
[127] "Montenegro"               "Montserrat"              
[129] "Morocco"                  "Mozambique"              
[131] "Namibia"                  "Nepal"                   
[133] "Netherlands"              "New Caledonia"           
[135] "New Zealand"              "Nicaragua"               
[137] "Niger"                    "Nigeria"                 
[139] "Niue"                     "North Korea"             
[141] "Northern Mariana Islands" "Norway"                  
[143] "Oman"                     "Pakistan"                
[145] "Palau"                    "Panama"                  
[147] "Papua New Guinea"         "Paraguay"                
[149] "Peru"                     "Philippines"             
[151] "Poland"                   "Portugal"                
[153] "Puerto Rico"              "Qatar"                   
[155] "Romania"                  "Russia"                  
[157] "Rwanda"                   "Saint Lucia"             
[159] "Samoa"                    "San Marino"              
[161] "Saudi Arabia"             "Senegal"                 
[163] "Serbia"                   "Seychelles"              
[165] "Sierra Leone"             "Singapore"               
[167] "Slovakia"                 "Slovenia"                
[169] "Solomon Islands"          "Somalia"                 
[171] "South Africa"             "South Korea"             
[173] "Spain"                    "Sri Lanka"               
[175] "Sudan"                    "Suriname"                
[177] "Swaziland"                "Sweden"                  
[179] "Switzerland"              "Syria"                   
[181] "Taiwan"                   "Tajikistan"              
[183] "Tanzania"                 "Thailand"                
[185] "Togo"                     "Tonga"                   
[187] "Tunisia"                  "Turkey"                  
[189] "Turkmenistan"             "Uganda"                  
[191] "Ukraine"                  "United Arab Emirates"    
[193] "United Kingdom"           "United States"           
[195] "Uruguay"                  "Uzbekistan"              
[197] "Venezuela"                "Vietnam"                 
[199] "Western Sahara"           "Yemen"                   
[201] "Zambia"                   "Zimbabwe"                
Code
table(unique(with_dep_by_year$country) %in% dta$Country.Name )

FALSE  TRUE 
   34   168 
Code
#Wanted to see the missing country 
test_data <-
  with_dep_by_year %>%
    filter(country %in% dta$Country.Name== FALSE )
unique(test_data$country)
 [1] "Anguilla"         "Antarctica"       "Bahamas"          "Cape Verde"      
 [5] "Christmas Island" "Côte d'Ivoire"    "Egypt"            "French Guiana"   
 [9] "Gambia"           "Gaza Strip"       "Guadeloupe"       "Guernsey"        
[13] "Hong Kong"        "Iran"             "Jersey"           "Kyrgyzstan"      
[17] "Laos"             "Macau"            "Martinique"       "Mayotte"         
[21] "Micronesia"       "Montserrat"       "Niue"             "North Korea"     
[25] "Russia"           "Saint Lucia"      "Slovakia"         "South Korea"     
[29] "Swaziland"        "Syria"            "Taiwan"           "Venezuela"       
[33] "Western Sahara"   "Yemen"           
Code
dta[dta=="Egypt, Arab Rep."] <- "Egypt"
dta[dta=="Russian Federation"] <-"Russia"
dta[dta=="Iran, Islamic Rep."] <-"Iran"
dta[dta=="Syrian Arab Republic"] <-"Syria"
dta[dta=="Yemen, Rep."] <-"Yemen"
dta[dta=="Slovak Republic"] <- "Slovakia"
dta[dta=="Venezuela, RB"] <- "Venezuela"
dta[dta=="Macao SAR, China"] <- "Macau"
dta[dta=="Hong Kong SAR, China"] <- "Hong Kong"
with_dep_by_year[with_dep_by_year=="Bahamas"] <-"Bahamas, The"
with_dep_by_year[with_dep_by_year=="French Guiana"] <- "Guyana"
with_dep_by_year[with_dep_by_year=="Gambia"] <- "Gambia, The"
Code
dta1 <- dta %>%
  pivot_longer(!Country.Name & !Code, names_to = "Year", values_to = "GDP") 
Code
#There is x infront of each year in the dataset so I removed the first character  
dta1$Year <- substring(dta1$Year, 2)
dta1 <- dta1 %>%
  rename(country = Country.Name)
dta2 <- dta1[,-2]
Code
sapply(dta2, function(x) sum(is.na(x)))
country    Year     GDP 
      0       0    3652 
Code
#drop the missing rows
dta3 <- na.omit(dta2)
Code
dta3_mean_gdp <- dta3 |> group_by(country) |> summarise(country_mean = mean(GDP,na.rm=TRUE))

Now that we have one measure of GDP for each country, we need one single measure of departure to find out the relation between GDP and temperature change.

For this single measure of departure, we average all departures from 1950 until the end.

Code
df0 <- country_temps |> group_by(country) |> filter(dt>'1950-12-01') |> summarise(avg_depart = mean(departure,na.rm = TRUE)) |> arrange(desc(avg_depart)) 
Code
country_gdp <- df0 |> left_join(dta3_mean_gdp, by = 'country')
Code
#there are small country like 'Anguilla'
country_gdp <- na.omit(country_gdp)
Code
#Run this code twice to remove longitude and latitude
country_gdp <- country_gdp[,-1]
Code
gdp_lm <- lm(avg_depart ~ country_mean, data = country_gdp) 

summary(gdp_lm)

Call:
lm(formula = avg_depart ~ country_mean, data = country_gdp)

Residuals:
     Min       1Q   Median       3Q      Max 
-1.07382 -0.18463 -0.03591  0.07786  1.30632 

Coefficients:
              Estimate Std. Error t value Pr(>|t|)    
(Intercept)  8.820e-01  2.594e-02  34.001   <2e-16 ***
country_mean 2.965e-14  3.174e-14   0.934    0.352    
---
Signif. codes:  0 '***' 0.001 '**' 0.01 '*' 0.05 '.' 0.1 ' ' 1

Residual standard error: 0.283 on 127 degrees of freedom
Multiple R-squared:  0.006822,  Adjusted R-squared:  -0.0009979 
F-statistic: 0.8724 on 1 and 127 DF,  p-value: 0.3521
Code
country_gdp |> ggplot(aes(avg_depart,country_mean)) + geom_point()

The results of a linear model between the departures and the GDP are not showing a clear linear relation. The coefficient 2.971e-14 is very small suggesting that GDP is not that significant of a metric to determine the average departure of temperatures.

There could be many other factors, such as HDI, that influence the extent to which temperatures deviate from the baseline. In other words, we will need a more complex model.

Conclusion

In summary, this report’s findings do not deviate from what is already well-known. Global temperatures have been rising steadily because of climate change and humanization. We hypothesized that the sharpest increase in temperatures occurred within the last 50 years. The data supports this conclusion. However, the deviations in temperature are not uniform; some countries have been affected more than others. Research regarding climate change suggests that high-latitude countries are seeing more significant temperature deviations. Many factors contribute to these shifts, for example, positive feedback, which results from melting ice absorbing the sun’s warmth rather than the solid ice reflecting it. Therefore, colder countries are seeing more shifts in weather and temperature patterns.

Furthermore, this report attempted to determine the relationship between GDP and temperature deviations. We hypothesized that countries with lower GDPs would have higher departures and, thus, are more susceptible to climate change. However, the linear model did not clearly define the correlation between these two variables. The model likely lacks complexity; there are many interacting variables, each of which could affect the extent to which temperatures are affected. For example, the human development index (HDI). Nevertheless, the findings may serve as the foundation for further research.